package View;

import java.awt.Color;
import java.awt.Graphics;
import java.util.LinkedList;
import java.util.Observable;
import java.util.Observer;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.border.BevelBorder;

import Model.Node;

public class GamePanel extends JPanel  implements Observer{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static final int WIDTH=500;
	public static final int HEIGHT=500;
	private LinkedList<Node> body;
	
	public GamePanel() {
		// TODO Auto-generated constructor stub
		setSize(WIDTH, HEIGHT);
		setBackground(Color.pink);
		setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
		
	}
	@Override
	public void paint(Graphics g) {
		// TODO Auto-generated method stub
		super.paint(g);
		if(body==null)return;
		Color color=Color.WHITE;
		for (Node n:body) {
			g.setColor(color);
			g.fill3DRect(n.getX(), n.getY(), Node.WIDTH, Node.HEIGHT, true);
			color=color.getRGB()==Color.WHITE.getRGB()?Color.BLACK:Color.WHITE;			
		}
	}
public void update(Observable o,Object arg) {
	// TODO Auto-generated method stub
	body=(LinkedList<Node>) arg;
	repaint();
}
}
